<?php

class EditDeleteFormScript extends ScriptBlock
{

	function __construct ()
	{
	$html =  "<script language = \"javascript\">\n";
	$html .= "function viewFile(FileID, DBTableName, ResourceID)\n";
	$html .= "{\n";
	$html .= "document.getElementById(\"Action\").value = \"ViewFile\";\n";
	$html .= "document.getElementById(\"FileID\").value = FileID;\n";
	$html .= "document.getElementById(\"DBTableName\").value = DBTableName;\n";
	$html .= "document.getElementById(\"ResourceID\").value = ResourceID;\n";

//	$html .= "alert('File '+FileID+'Resource '+ResourceID);\n";
	$html .= "if(document.getElementById('OverrideDivAction')!=null){";
	$html .= "document.getElementById('OverrideDivAction').value='True';}\n";

	
	$html .= "document.getElementById(\"PageForm\").submit();\n";
	$html .= "}\n";
	$html .= "function deleteFile(ResourceID, FileID, DBTableName)\n";
	$html .= "{\n";
	$html .= "document.getElementById(\"Action\").value = \"DeleteFile\";\n";
	$html .= "document.getElementById(\"FileID\").value = FileID;\n";
	$html .= "document.getElementById(\"ResourceID\").value = ResourceID;\n";
	$html .= "document.getElementById(\"DBTableName\").value = DBTableName;\n";
	$html .= "document.getElementById(\"SubAction\").value = \"EditResource\";\n";
	$html .= "document.getElementById(\"PageForm\").submit();\n";
	$html .= "}\n";
	$html .= "function viewRecord(ID, DBTableName)\n";
	$html .= "{\n";
	$html .= "document.getElementById(\"Action\").value = \"ViewRecord\";\n";
	$html .= "document.getElementById(\"RecordID\").value = ID;\n";
	$html .= "document.getElementById(\"DBTableName\").value = DBTableName;\n";
	$html .= "document.getElementById(\"PageForm\").submit();\n";
	$html .= "}\n";
	$html .= "function editRecord(ID, DBTableName)\n";
	$html .= "{\n";
	$html .= "document.getElementById(\"Action\").value = \"EditRecord\";\n";
	$html .= "document.getElementById(\"RecordID\").value = ID;\n";
	$html .= "document.getElementById(\"DBTableName\").value = DBTableName;\n";
	$html .= "document.getElementById(\"PageForm\").submit();\n";
	$html .= "}\n";
	$html .= "function deleteRecord(ID, DBTableName)\n";
	$html .= "{\n";
	$html .= "var r = 	confirm(\"Do you really want to delete this event\");\n";
	$html .= "if (r==true)\n";
	$html .= "{\n";
	$html .= "document.getElementById(\"Action\").value = \"DeleteRecord\";\n";
	$html .= "document.getElementById(\"RecordID\").value = ID;\n";
	$html .= "document.getElementById(\"DBTableName\").value = DBTableName;\n";
	$html .= "document.getElementById(\"PageForm\").submit();\n";
	$html .= "}\n";
	$html .= "}\n";
	$html .= "function newRecord(DBTableName)\n";
	$html .= "{\n";
	$html .= "document.getElementById(\"Action\").value = \"NewRecord\";\n";
	$html .= "document.getElementById(\"RecordID\").value = \"\";\n";
	$html .= "document.getElementById(\"DBTableName\").value = DBTableName;\n";
	$html .= "document.getElementById(\"PageForm\").submit();\n";
	$html .= "}\n";
	$html .= "function newDatedRecord(DBTableName,Date)\n";
	$html .= "{\n";
	$html .= "document.getElementById(\"Action\").value = \"NewRecord\";\n";
	$html .= "document.getElementById(\"RecordID\").value = \"\";\n";
	$html .= "document.getElementById(\"NewRecordDate\").value = Date;\n";
	$html .= "document.getElementById(\"DBTableName\").value = DBTableName;\n";
	$html .= "document.getElementById(\"PageForm\").submit();\n";
	$html .= "}\n";
	$html .= "</script>\n";
	$this->scriptHTML = $html;
	}
}